package com.css.gdzj.gdzjbxgd.modules.reportinfo.service.impl;

import com.css.gdzj.gdzjbxgd.common.util.R;
import com.css.gdzj.gdzjbxgd.common.util.ServiceUtil;
import com.css.gdzj.gdzjbxgd.common.util.StringHelper;
import com.css.gdzj.gdzjbxgd.modules.reportcontral.repository.BxgdReportContralRepository;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.repository.*;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.repository.entity.BxgdReportInfoEntity;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.repository.entity.BxgdReportInfoEntityVo;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.repository.entity.HonestGiftChildEntity;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.repository.entity.HonestPtjobChildEntity;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.service.BxgdReportInfoService;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.service.HonestGiftChildService;
import com.css.gdzj.gdzjbxgd.modules.reportinfo.service.HonestPtjobChildService;
import com.css.gdzj.gdzjbxgd.modules.userinfo.repository.UserInfoRepository;
import com.css.gdzj.gdzjbxgd.modules.userinfo.repository.entity.UserInfoEntity;
import com.css.gdzj.gdzjbxgd.modules.userinfo.service.UserInfoService;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * @author wxx
 * @date 2020-12-11
 */
@Service
public class BxgdReportInfoServiceImpl implements BxgdReportInfoService {

    @Autowired
    private BxgdReportContralRepository bxgdReportContralRepository;
    @Autowired
    private BxgdReportInfoRepository bxgdReportInfoRepository;
    @Autowired
    private HonestGiftChildRepository honestGiftChildRepository;
    @Autowired
    private HonestPtjobChildRepository honestPtjobChildRepository;
    @Autowired
    private BxgdReportInfoNativeRepository bxgdReportInfoNativeRepository;
    @Autowired
    private HonestGiftChildNativeRepository honestGiftChildNativeRepository;
    @Autowired
    private HonestPtjobChildNativeRepository HonestPtjobChildNativeRepository;
    @Autowired
    HttpServletRequest request;
    //注入JPAQueryFactory工厂
    @Autowired
    JPAQueryFactory jpaQueryFactory;
    @Autowired
    private ServiceUtil serviceUtil;
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private HonestGiftChildService honestGiftChildService;
    @Autowired
    private HonestPtjobChildService honestPtjobChildService;
    @Autowired
    private UserInfoRepository userInfoRepository;

    @Override
    public List<BxgdReportInfoEntity> queryBxgdReportInfos(String reportYear, Integer pageNo, Integer pageSize) {
        R r = serviceUtil.getUserInfoByRequest(request);
        String loginUserId = null;
        if (r.getCode().equals("200")) {
            //LoginUser loginUser = (LoginUser)r.get("data");
            UserInfoEntity loginUser = (UserInfoEntity) r.get("data");
            loginUserId = loginUser.getUserId();
        }
        List<BxgdReportInfoEntity> bxgdReportInfoPage = this.bxgdReportInfoNativeRepository.queryBxgdReportInfos(loginUserId, reportYear, pageNo, pageSize);
        return (null != bxgdReportInfoPage && bxgdReportInfoPage.size() > 0) ? bxgdReportInfoPage : null;
    }

   /* @Override
    public List<Object> queryAllReportInfos(Map<String, String> params, Integer pageNo, Integer pageSize) {
        String reportYear = params.get("reportYear");

        if (StringHelper.isEmpty(reportYear)) {
            reportYear = bxgdReportContralRepository.queryReportYear();
        }

        String userName = params.get("userName");
        String loginName = params.get("loginName");
        String userUnit = params.get("userUnit");
        String userLeaderPost = params.get("userLeaderPost");
        String userRank = params.get("userRank");
        String userPoliticalOutlook = params.get("userPoliticalOutlook");
        Map<String, Object> mapUser = new HashMap<>();
        String userId, reportId = null;
        mapUser = userInfoService.queryAllUserInfos(loginName, userName, userPoliticalOutlook, userRank, userLeaderPost, userUnit);
        List<UserInfoEntity> listUserInfo = (List) mapUser.get("listUserInfo");
        List<Object> objects = new ArrayList<>();
        for (UserInfoEntity userInfoEntity : listUserInfo) {
            Map<String, Object> map = new HashMap<>();
            UserInfoEntity entity = new UserInfoEntity();
            entity.setUserId(userInfoEntity.getUserId());
            entity.setUserName(userInfoEntity.getUserName());//用户名
            entity.setLoginName(userInfoEntity.getLoginName());//账号
            entity.setUserUnit(userInfoEntity.getUserUnit());//用户单位
            entity.setUserPoliticalOutlook(userInfoEntity.getUserPoliticalOutlook());//政治面貌
            entity.setUserLeaderPost(userInfoEntity.getUserLeaderPost());//领导职务
            userId = userInfoEntity.getUserId();
            List<BxgdReportInfoEntity> bxgdReportInfoPage = this.bxgdReportInfoNativeRepository.queryBxgdReportInfos(userId, reportYear, pageNo, pageSize);
            mapUser.put("bxgdReportInfoPage", bxgdReportInfoPage);

            List<BxgdReportInfoEntity> bxgdInfoList = (List) mapUser.get("bxgdReportInfoPage");
            if (null != bxgdInfoList && bxgdInfoList.size() > 0) {
                BxgdReportInfoEntity bxgdReportInfoEntity = bxgdReportInfoPage.get(0);
//                for (BxgdReportInfoEntity bxgdReportInfoEntity : bxgdInfoList) {
                    BxgdReportInfoEntityVo bxgdReportInfoEntityVo = new BxgdReportInfoEntityVo();
                    bxgdReportInfoEntityVo.setBxgdReportInfoEntity(bxgdReportInfoEntity);
                    reportId = bxgdReportInfoEntity.getReportId();
                    if (bxgdReportInfoEntity.getHonestGift().equals("1")) {
                        List<HonestGiftChildEntity> giftChildEntities = honestGiftChildService.getList(reportId);
                        bxgdReportInfoEntityVo.setHonestGiftChildEntityList(giftChildEntities);
                    }
                    if (bxgdReportInfoEntity.getHonestPtjob().equals("1")) {
                        List<HonestPtjobChildEntity> ptjobChildEntities = honestPtjobChildService.getList(reportId);
                        bxgdReportInfoEntityVo.setHonestPtjobChildEntityList(ptjobChildEntities);
                    }
    //                    map.put(userInfoEntity, bxgdReportInfoEntityVo);
                    map.put("userInfoEntity", entity);
                    map.put("bxgdReportInfoEntityVo", bxgdReportInfoEntityVo);
                    objects.add(map);
//                }
            }
        }
        return objects;
    }
*/
  /*  @Override
    public List<Object> queryAllInfosCount(Map<String, String> params) {
        String reportYear = params.get("reportYear");
        String userName = params.get("userName");
        String loginName = params.get("loginName");
        String userUnit = params.get("userUnit");
        String userLeaderPost = params.get("userLeaderPost");
        String userRank = params.get("userRank");
        String userPoliticalOutlook = params.get("userPoliticalOutlook");

        Map<String, Object> mapUser = new HashMap<>();
        String userId, reportId = null;
        mapUser = userInfoService.queryAllUserInfos(loginName, userName, userPoliticalOutlook, userRank, userLeaderPost, userUnit);
        List<UserInfoEntity> listUserInfo = (List) mapUser.get("listUserInfo");
//        Map<Object,Object> map = new HashMap<>();
        List<Object> objects = new ArrayList<>();
        for (UserInfoEntity userInfoEntity : listUserInfo) {
            userId = userInfoEntity.getUserId();
            List<BxgdReportInfoEntity> bxgdReportInfoPage = this.bxgdReportInfoNativeRepository.queryBxgdReportInfosCount(userId, reportYear);
            mapUser.put("bxgdReportInfoPage", bxgdReportInfoPage);

            List<BxgdReportInfoEntity> bxgdInfoList = (List) mapUser.get("bxgdReportInfoPage");
            if (null != bxgdInfoList && bxgdInfoList.size() > 0) {
                BxgdReportInfoEntity bxgdReportInfoEntity = bxgdReportInfoPage.get(0);
//                for (BxgdReportInfoEntity bxgdReportInfoEntity : bxgdInfoList) {
                    BxgdReportInfoEntityVo bxgdReportInfoEntityVo = new BxgdReportInfoEntityVo();
                    bxgdReportInfoEntityVo.setBxgdReportInfoEntity(bxgdReportInfoEntity);
                    reportId = bxgdReportInfoEntity.getReportId();
                    if (bxgdReportInfoEntity.getHonestGift().equals("1")) {
                        List<HonestGiftChildEntity> giftChildEntities = honestGiftChildService.getList(reportId);
                        bxgdReportInfoEntityVo.setHonestGiftChildEntityList(giftChildEntities);
                    }
                    if (bxgdReportInfoEntity.getHonestPtjob().equals("1")) {
                        List<HonestPtjobChildEntity> ptjobChildEntities = honestPtjobChildService.getList(reportId);
                        bxgdReportInfoEntityVo.setHonestPtjobChildEntityList(ptjobChildEntities);
                    }
                    objects.add(bxgdReportInfoEntityVo);
//                }
            }
        }
        return (null != objects && objects.size() > 0) ? objects : null;
    }
*/
    @Override
    public List<BxgdReportInfoEntity> queryBxgdReportInfosCount(String reportYear) {
        R r = serviceUtil.getUserInfoByRequest(request);
        String loginUserId = null;
        if (r.getCode().equals("200")) {
            //LoginUser loginUser = (LoginUser)r.get("data");
            UserInfoEntity loginUser = (UserInfoEntity) r.get("data");
            loginUserId = loginUser.getUserId();
        }
        List<BxgdReportInfoEntity> bxgdReportInfoPage = this.bxgdReportInfoNativeRepository.queryBxgdReportInfosCount(loginUserId, reportYear);
        return (null != bxgdReportInfoPage && bxgdReportInfoPage.size() > 0) ? bxgdReportInfoPage : null;

    }


    @Override
    public BxgdReportInfoEntityVo getBxgdReportInfo(String id) {
        BxgdReportInfoEntityVo bxgdReportInfoEntityVo = new BxgdReportInfoEntityVo();
//        BxgdReportInfoEntity bxgdReportInfo = this.bxgdReportInfoRepository.findById(id).orElse(null);
        List<BxgdReportInfoEntity> info = bxgdReportInfoNativeRepository.getBxgdReportInfo(id);
        if (null != info && info.size() > 0) {
            BxgdReportInfoEntity bxgdReportInfoEntity = info.get(0);
            String reportId = bxgdReportInfoEntity.getReportId();
            List<HonestGiftChildEntity> honestGiftChildEntityList = this.honestGiftChildNativeRepository.getList(reportId);
            List<HonestPtjobChildEntity> honestPtjobChildEntityList = this.HonestPtjobChildNativeRepository.getList(reportId);
            bxgdReportInfoEntityVo.setBxgdReportInfoEntity(bxgdReportInfoEntity);
            if (null != honestGiftChildEntityList && honestGiftChildEntityList.size() > 0) {
                bxgdReportInfoEntityVo.setHonestGiftChildEntityList(honestGiftChildEntityList);
            }
            if (null != honestPtjobChildEntityList && honestPtjobChildEntityList.size() > 0) {
                bxgdReportInfoEntityVo.setHonestPtjobChildEntityList(honestPtjobChildEntityList);
            }
        }

        return bxgdReportInfoEntityVo;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public BxgdReportInfoEntity saveBxgdReportInfo(BxgdReportInfoEntityVo bxgdReportInfoVo) {
        //String uuid = SnowflakeId.getId();
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        BxgdReportInfoEntity bxgdReportInfo = bxgdReportInfoVo.getBxgdReportInfoEntity();
        if (null == bxgdReportInfo)
            return null;
        bxgdReportInfo.setReportId(uuid);
        R r = serviceUtil.getUserInfoByRequest(request);
        String loginUserId = null;
        String createUserDept = null;
        if (r.getCode().equals("200")) {
            UserInfoEntity userInfoEntity = (UserInfoEntity) r.get("data");
            loginUserId = userInfoEntity.getUserId();
            createUserDept = userInfoEntity.getUserUnit();
//            userInfoEntity.setUserIsReport("0");//表示用户已填报
//            userInfoService.updateUserInfo(userInfoEntity);
        }
        bxgdReportInfo.setCreateUser(loginUserId);
        bxgdReportInfo.setCreateTime(new Date());
        //bxgdReportInfo.setUpdateTime(new Date());
        bxgdReportInfo.setCreateUserDept(createUserDept);

        /*SimpleDateFormat year = new SimpleDateFormat("yyyy");
        int reportYear = Integer.parseInt(year.format(new Date())) - 1;
        bxgdReportInfo.setReportYear(String.valueOf(reportYear));*/

        String reportYear = bxgdReportContralRepository.queryReportYear();
        bxgdReportInfo.setReportYear(reportYear);

        this.bxgdReportInfoRepository.save(bxgdReportInfo);

        List<HonestGiftChildEntity> honestGiftChildEntityList = bxgdReportInfoVo.getHonestGiftChildEntityList();
        if (null != honestGiftChildEntityList && honestGiftChildEntityList.size() > 0) {
            for (HonestGiftChildEntity entity : honestGiftChildEntityList) {
                String id = UUID.randomUUID().toString().replaceAll("-", "");
                entity.setUuid(id);
                entity.setReportId(bxgdReportInfo.getReportId());
            }
            this.honestGiftChildRepository.saveAll(honestGiftChildEntityList);
        }
        List<HonestPtjobChildEntity> honestPtjobChildEntityList = bxgdReportInfoVo.getHonestPtjobChildEntityList();
        if (null != honestGiftChildEntityList && honestPtjobChildEntityList.size() > 0) {
            for (HonestPtjobChildEntity entity : honestPtjobChildEntityList) {
                String id = UUID.randomUUID().toString().replaceAll("-", "");
                entity.setUuid(id);
                entity.setReportId(bxgdReportInfo.getReportId());
            }
            this.honestPtjobChildRepository.saveAll(honestPtjobChildEntityList);
        }
        return bxgdReportInfo;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public BxgdReportInfoEntity updateBxgdReportInfo(BxgdReportInfoEntityVo bxgdReportInfoVo) {
        BxgdReportInfoEntity bxgdReportInfo = bxgdReportInfoVo.getBxgdReportInfoEntity();
        R r = serviceUtil.getUserInfoByRequest(request);
        String loginUserId = null;
        if (r.getCode().equals("200")) {
            UserInfoEntity userInfoEntity = (UserInfoEntity) r.get("data");
            loginUserId = userInfoEntity.getUserId();
        }
        bxgdReportInfo.setUpdateUser(loginUserId);
        bxgdReportInfo.setUpdateTime(new Date());
        this.bxgdReportInfoRepository.save(bxgdReportInfo);

        String reportId = bxgdReportInfo.getReportId();
        List<HonestGiftChildEntity> giftChildEntities = this.honestGiftChildNativeRepository.getList(reportId);
        if (null != giftChildEntities && giftChildEntities.size() > 0) {
            this.honestGiftChildRepository.deleteAll(giftChildEntities);
        }
        List<HonestPtjobChildEntity> ptjobChildEntities = this.HonestPtjobChildNativeRepository.getList(reportId);
        if (null != ptjobChildEntities && ptjobChildEntities.size() > 0) {
            this.honestPtjobChildRepository.deleteAll(ptjobChildEntities);
        }

        List<HonestGiftChildEntity> honestGiftChildEntityList = bxgdReportInfoVo.getHonestGiftChildEntityList();
        if (honestGiftChildEntityList.size() > 0 && honestGiftChildEntityList != null) {
          /*  for (int i = 0; i < honestGiftChildEntityList.size(); i++) {
                this.honestGiftChildRepository.save(honestGiftChildEntityList.get(i));
            }*/
            for (HonestGiftChildEntity honestGiftChildEntity : honestGiftChildEntityList) {
                honestGiftChildEntity.setReportId(reportId);
                this.honestGiftChildRepository.save(honestGiftChildEntity);
            }
        }
        List<HonestPtjobChildEntity> honestPtjobChildEntityList = bxgdReportInfoVo.getHonestPtjobChildEntityList();
        if (null != honestPtjobChildEntityList && honestPtjobChildEntityList.size() > 0) {
            /*for (int i = 0; i < honestPtjobChildEntityList.size(); i++) {
                this.honestPtjobChildRepository.save(honestPtjobChildEntityList.get(i));
            }*/
            for (HonestPtjobChildEntity honestGiftChildEntity : honestPtjobChildEntityList) {
                honestGiftChildEntity.setReportId(reportId);
                this.honestPtjobChildRepository.save(honestGiftChildEntity);
            }
        }
        return bxgdReportInfo;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteBxgdReportInfos(List<String> ids) {
        if (null != ids && ids.size() > 0) {
            for (int i = 0; i < ids.size(); i++) {
                BxgdReportInfoEntity bxgdReportInfoEntity = this.bxgdReportInfoRepository.getOne(ids.get(i));
                this.bxgdReportInfoRepository.delete(bxgdReportInfoEntity);
                List<HonestGiftChildEntity> honestGiftChildEntityList = this.honestGiftChildNativeRepository.getList(ids.get(i));
                this.honestGiftChildRepository.deleteAll(honestGiftChildEntityList);
                List<HonestPtjobChildEntity> honestPtjobChildEntityList = this.HonestPtjobChildNativeRepository.getList(ids.get(i));
                this.honestPtjobChildRepository.deleteAll(honestPtjobChildEntityList);
            }
        }
    }

    @Override
    public List<Object> queryAllReportInfos1(Map<String, String> params, Integer pageNo, Integer pageSize, Pageable pageable) {
        String reportYear = params.get("reportYear");

        if (StringHelper.isEmpty(reportYear)) {
            reportYear = bxgdReportContralRepository.queryReportYear();
        }

        String userName = params.get("userName");
        String loginName = params.get("loginName");
        String userUnit = params.get("userUnit");
        String userLeaderPost = params.get("userLeaderPost");
        String userRank = params.get("userRank");
        String userPoliticalOutlook = params.get("userPoliticalOutlook");
        String userId, reportId = null;
        Page<UserInfoEntity> listUserInfo = userInfoRepository.getIsReportPage(userUnit, reportYear, loginName, userName, userPoliticalOutlook, userRank, userLeaderPost, pageable);

        List<Object> objects = new ArrayList<>();
        for (UserInfoEntity userInfoEntity : listUserInfo) {
            Map<String, Object> map = new HashMap<>();
            UserInfoEntity entity = new UserInfoEntity();
            entity.setUserId(userInfoEntity.getUserId());
            entity.setUserName(userInfoEntity.getUserName());//用户名
            entity.setLoginName(userInfoEntity.getLoginName());//账号
            entity.setUserUnit(userInfoEntity.getUserUnit());//用户单位
            entity.setUserPoliticalOutlook(userInfoEntity.getUserPoliticalOutlook());//政治面貌
            entity.setUserLeaderPost(userInfoEntity.getUserLeaderPost());//领导职务
            userId = userInfoEntity.getUserId();
            List<BxgdReportInfoEntity> bxgdReportInfoPage = this.bxgdReportInfoNativeRepository.queryBxgdReportInfos(userId, reportYear, pageNo, pageSize);
            if (null != bxgdReportInfoPage && bxgdReportInfoPage.size() > 0) {
                BxgdReportInfoEntity bxgdReportInfoEntity = bxgdReportInfoPage.get(0);
//                for (BxgdReportInfoEntity bxgdReportInfoEntity : bxgdReportInfoPage) {
                BxgdReportInfoEntityVo bxgdReportInfoEntityVo = new BxgdReportInfoEntityVo();
                bxgdReportInfoEntityVo.setBxgdReportInfoEntity(bxgdReportInfoEntity);
                reportId = bxgdReportInfoEntity.getReportId();
                if (bxgdReportInfoEntity.getHonestGift().equals("1")) {
                    List<HonestGiftChildEntity> giftChildEntities = honestGiftChildService.getList(reportId);
                    bxgdReportInfoEntityVo.setHonestGiftChildEntityList(giftChildEntities);
                }
                if (bxgdReportInfoEntity.getHonestPtjob().equals("1")) {
                    List<HonestPtjobChildEntity> ptjobChildEntities = honestPtjobChildService.getList(reportId);
                    bxgdReportInfoEntityVo.setHonestPtjobChildEntityList(ptjobChildEntities);
                }
                map.put("userInfoEntity", entity);
                map.put("bxgdReportInfoEntityVo", bxgdReportInfoEntityVo);
                objects.add(map);
//                }
            }
        }
        return objects;
    }
    /*@Override
    public void exportExcel(String surveyFour, Integer pageNo, Integer pageSize){
    List<BxgdReportInfoEntity> bxgdReportInfoList = bxgdReportInfoNativeRepository.queryBxgdReportInfo(queryParams);
    List<BxgdReportInfoExportExcelVO> excelVos = new ArrayList<>();

    bxgdReportInfoList.forEach(e->{
    BxgdReportInfoExportExcelVO bxgdReportInfoExcelVo = new BxgdReportInfoExportExcelVO();
    BeanUtils.copyProperties(e,bxgdReportInfoExcelVo);
    excelVos.add(bxgdReportInfoExcelVo);
    });
    Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(null, "bxgd_report_info"), BxgdReportInfoExportExcelVO.class, excelVos);
    PlatformDownloadUtils.exportExcel(workbook, "bxgd_report_info.xls", response);

    }
    @Override
    public String uploadFile(MultipartFile file, HttpServletResponse response) {
    try{
    StringBuilder returnMsg = new StringBuilder();
    ImportParams params = new ImportParams();
    params.setHeadRows(1);
    params.setNeedVerify(true);

    ExcelImportResult<BxgdReportInfoExcelVO> result = ExcelImportUtil.importExcelMore(file.getInputStream(),BxgdReportInfoExcelVO.class,params);
    List<BxgdReportInfoExcelVO> bxgdReportInfoExcelVoList = result.getFailList();
    for(int i = 0;i<bxgdReportInfoExcelVoList.size();i++){
        BxgdReportInfoExcelVO bxgdReportInfoExcelVo = bxgdReportInfoExcelVoList.get(i);
        String msg = bxgdReportInfoExcelVo.getErrorMsg();
        Integer num = bxgdReportInfoExcelVo.getRowNum();
        if(PlatformObjectUtils.checkFieldAllNull(bxgdReportInfoExcelVo)){
        bxgdReportInfoExcelVoList.remove(i);
        i--;
    }else{
        bxgdReportInfoExcelVo.setRowNum(num);
        bxgdReportInfoExcelVo.setErrorMsg(msg);
            }
    }

    List<BxgdReportInfoEntity>  dataEntityList = new ArrayList<>();
    List<BxgdReportInfoExcelVO> list = result.getList();
            list.forEach(e->{
            BxgdReportInfoEntity dataEntity = new BxgdReportInfoEntity();
            BeanUtils.copyProperties(e,dataEntity);
            dataEntity.setId(UUIDGenerator.getUUID());
            dataEntity.setCreateTime(PlatformDateUtils.getCurrentTimestamp());
            dataEntity.setCreateUser(PlatformSessionUtils.getUserId());
            dataEntityList.add(dataEntity);
            });
    bxgdReportInfoRepository.saveAll(dataEntityList);
    int successListSize = list.size() - bxgdReportInfoExcelVoList.size();
    returnMsg.append("成功导入" + successListSize + "条，失败" + bxgdReportInfoExcelVoList + "条");

    for (BxgdReportInfoExcelVO entity : result.getFailList()) {
        String msg = "";
        returnMsg.append("第" + entity.getRowNum() + "行" + entity.getErrorMsg() + "<br/>");
        returnMsg.append(msg);
    }
    return returnMsg.toString();
    }catch (Exception e){
        e.printStackTrace();
    return "导入失败，请检查数据正确性";

    }
   }*/

}
